<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<body class="easyui-layout">
<!-- 说明 字符串：Campany，作为替换字符串 -->
<div class="easyui-layout" style="width:100%;height:100%;">
	<!-- 主表  -->
	<table id="campany_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
		   data-options="rownumbers:true, pagination:true,singleSelect:true,url:'/campany-list/1/20',
					  method:'get',
					  toolbar:'#tb',
					  loadMsg : '数据加载中',				 
					  showFooter: true" >
		<#include "/common/thead.html">
	</table>
</div>

<!-- 搜索框 -->
<div id="tb" style="padding:5px;height:auto">
	<div>
        模板名称1:<input class="easyui-textbox" id="to" style="width:120px" >
		<a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
	</div>
    <div style="margin:5px 0;"></div>
    <#include "/common/button.html">
</div>

 <#include "/common/dlg.html">


<!-- 按钮操作 -->
<script type="text/javascript">
	var url;

    //新增
    $("#add").click(function () {
		$('#dlg').dialog('open').dialog('center').dialog('setTitle','新增角色');
		$('#fm').form('clear');
		url = '/campany-ins-upd-del/-1';		
    })
	
    //编辑
    $("#edit").click(function () {
		
		var row = $('#campany_table').datagrid('getSelected');
		if (row){
            $('#dlg').dialog('open').dialog('center').dialog('setTitle','编辑');
            $('#fm').form('load',row);
            url = '/campany-ins-upd-del/'+row.id;
		} else {
            layer.msg("请选择需要编辑的项目",{icon: 2})
		}
    })
	//行复制
    $("#copy").click(function () {
		
		var row = $('#campany_table').datagrid('getSelected');
		if (row){
            $('#dlg').dialog('open').dialog('center').dialog('setTitle','编辑');
            $('#fm').form('load',row);
            url = '/campany-ins-upd-del/-1';
		} else {
            layer.msg("请选择需要复制的行的项目",{icon: 2})
		}
    })
	
	function save(){
        $('#fm').form('submit',{
            url: url,
            onSubmit: function(){
                return $(this).form('validate');
            },
            success: function(result){
				$('#dlg').dialog('close');        // close the dialog
				$('#campany_table').datagrid('reload');    // reload the user data
            }
        });
    }

    //删除
    $("#delete").click(function () {
	
		var row = $('#campany_table').datagrid('getSelected');
		if(!row){
            layer.msg("请选择需要删除的项目",{icon: 2})
		}else{
            url = '/campany-ins-upd-del/'+row.id;
            $.messager.confirm('删除信息','确定删除此项目?',function(r){
                if (r){
                    $.post(url,{deleteFlag:'Y',tm:new Date()},function(result){                        
						$('#campany_table').datagrid('reload');    // reload the user data
                    });
                }
            });
		}	
    })
	$('#export').click(function(){
        window.location = "/campany-download";
    });
</script>

<!-- 分页 -->
<script type="text/javascript">
	$(function(){
		var p = $('#campany_table').datagrid().datagrid('getPager');
		p.pagination({
			pageSize: 20, //每页显示的记录条数，默认为10
			pageList: [20, 40, 60], //可以设置每页记录条数的列表
			onSelectPage: function (pageNumber, pageSize) {
			    if(pageNumber==0){
			        pageNumber = 1;
                }
				var handler = '/campany-list/'+pageNumber+"/"+pageSize;
				$('#campany_table').datagrid('options').url = handler;
				$('#campany_table').datagrid('reload');
			}
		});
	})
</script>